package com.bc.bczbweb.controller.Ajax;

import com.bc.bcmodel.domain.T_Mnguser_infoModel;
import com.bc.commonentity.common.JsonResult;
import com.bc.bcapi.service.T_Mng_quartzserviceService;
import com.bc.bcmodel.domain.T_Mng_quartzserviceModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.ws.rs.POST;
import java.math.BigInteger;

@RestController
@RequestMapping("ajax/t_mng_quartzservice")
public class AjaxT_Mng_quartzserviceController {
    @Autowired
    T_Mng_quartzserviceService t_Mng_quartzserviceService;

    @POST
    @RequestMapping(value = "add", method = RequestMethod.POST)
    public JsonResult add(T_Mng_quartzserviceModel req) {
        JsonResult js = new JsonResult();
        if (req.getId() != null && req.getId().intValue() > 0) {
            t_Mng_quartzserviceService.update(req);
        } else {
            t_Mng_quartzserviceService.insert(req);
        }
        return js;
    }

    @RequestMapping(value = "del", method = RequestMethod.POST)
    public JsonResult del(BigInteger id) {
        JsonResult js = new JsonResult();
        T_Mng_quartzserviceModel model = new T_Mng_quartzserviceModel();
        model.setId(id);
        T_Mng_quartzserviceModel result = t_Mng_quartzserviceService.findByNamedParam(model);

        model = new T_Mng_quartzserviceModel();
        model.setId(id);
        int status = 1;
        if (result.getIs_start().equals(1)) {
            status = 0;
        }
        model.setIs_start(status);
        t_Mng_quartzserviceService.update(model);
        return js;
    }
}